package com.boang.service;

import com.boang.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/*
  @author: 13813
  @date: 2024/7/25 9:51
*/
//@Transactional(propagation = Propagation.REQUIRED, timeout = -1, readOnly = true)
@Service("accountService")
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Transactional(propagation = Propagation.REQUIRED, timeout = -1, readOnly = false)
    @Override
    public void trans(String from, String to, int money) {
        //zhangsan减钱
        accountDao.updateAccount(from, -money);
        int i = 1 / 0;
        //lisi加钱
        accountDao.updateAccount(to, money);
    }
}
